package graph_viewer.util;

import java.awt.*;

import graph_viewer.gui.* ;
import graph_viewer.structure.*;
import graph_viewer.layout.* ;



public class GUI_Util{
	public static void main( String args[] ){
		find_screen_boundary();	
	}

	static int
		SCREEN_MENU_HEIGHT		= 60,
		SCREEN_BORDER_WIDTH	= 5;

	static public int get_screen_width_value(){
		return GUI.SCREEN_WIDTH;
	}

	static public int get_screen_height_value(){
		return GUI.SCREEN_HEIGHT;
	}	

	static public int get_canvas_width_value(){
		return get_screen_width_value() - SCREEN_BORDER_WIDTH ;
	}

	static public int get_canvas_height_value(){
		return get_screen_height_value() - SCREEN_MENU_HEIGHT;
	}	

	static public int get_canvas_x_start_value(){
		return GUI.CANVAS_START_X;
	}

	static public int get_canvas_y_start_value(){
		return GUI.CANVAS_START_Y;
	}	
	
	// this is the boundary used to distort graph
	// it also is the root node boundary in inclusion tree layout 
	static public Node_Position find_screen_boundary(){
		int
			canvas_width	= get_canvas_width_value(),
			canvas_height	= get_canvas_height_value(),
			canvas_start_x	= get_canvas_x_start_value(),
			canvas_start_y	= get_canvas_y_start_value();
		
		int
			canvas_net_width	= canvas_width - canvas_start_x,
			canvas_net_height	= canvas_height - canvas_start_y;

		//Debug.println( "canvas_width : " + canvas_net_width, 2 );
		//Debug.println( "canvas_height : " + canvas_net_height, 2 );

		Fisheye_Point canvas_center = new Fisheye_Point( canvas_net_width/2, canvas_net_height/2 );

		int 
			x_margin	= Layout.NODE_MARGIN,
			y_margin	= Layout.NODE_MARGIN;

		Node_Position	np	 = new Node_Position( canvas_center, canvas_net_width - 2 *  x_margin, canvas_net_height - 2 * y_margin );
		
		return np;
	}

	static public Rectangle find_screen_range(){
		int
			canvas_width		= get_canvas_width_value(),
			canvas_height		= get_canvas_height_value(),
			canvas_start_x	= get_canvas_x_start_value(),
			canvas_start_y	= get_canvas_y_start_value();

		return new Rectangle(canvas_start_x, canvas_start_y, canvas_width, canvas_start_x);
	}

	static public int[] find_screen_center(){
		Node_Position	screen_boundary		= GUI_Util.find_screen_boundary();
		int[]	screen_center_point	= screen_boundary.find_center();

		return screen_center_point;
	}
}